package main

import (
	"Push/config"
	"Push/src/SMS"
	"Push/src/dingding"
	"Push/src/mail"
	"Push/util"
	"log"
)

func main() {
	Config := &config.DefaultMailConfigProvider{}
	// 创建 LogGer 实例
	LogGer := util.LogGer{}
	log.Println(Config.GetMailConfig().LogGer.LogFile)
	LogGer.Init(Config.GetMailConfig().LogGer.LogFile)
	log.Println(Config.GetMailConfig().BeforeAndAfterCommands.BeforeStatus)
	if Config.GetMailConfig().BeforeAndAfterCommands.BeforeStatus == 1 {
		if len(Config.GetMailConfig().BeforeAndAfterCommands.BeforeStatusCommand) > 0 {
			out, err := SMS.SMSCmd(Config.GetMailConfig().BeforeAndAfterCommands.BeforeStatusCommand)
			if err != nil {
				log.Println("命令执行错误：", err)
				return
			}
			log.Println("命令执行成功", out)
		}
	}
	if Config.GetMailConfig().Status.Mail == 1 {
		mail.Mail(Config)
	}
	if Config.GetMailConfig().Status.DingDing == 1 {
		dingding.DingDing(Config)
	}
	if Config.GetMailConfig().Status.SMS == 1 {
		SMS.SmsSend(Config)
	}
	if Config.GetMailConfig().BeforeAndAfterCommands.AfterStatus == 1 {
		if len(Config.GetMailConfig().BeforeAndAfterCommands.AfterCommand) > 0 {
			out, err := SMS.SMSCmd(Config.GetMailConfig().BeforeAndAfterCommands.AfterCommand)
			if err != nil {
				log.Println("命令执行错误：", err)
				return
			}
			log.Println("命令执行成功", out)
		}
	}
}
